﻿using System;

class Test
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 7 Dec 2011 Morning

        checked
        {
            string number = Console.ReadLine();
            int result = 0;

            while (true)
            {
                for (int i = 0; i < number.Length; i++)
                {
                    if (!(number[i] == '.' || number[i] == '-'))
                    {
                        result = result + int.Parse(number[i].ToString());
                    }
                }
                if (result < 10)
                {
                    break;
                }
                number = result.ToString();
                result = 0;
            }
            Console.WriteLine(result);
        }
    }
}

